package Game;

public class Cell implements ITargetable, IAffectable {
	/**
	 * Cell's x coordinate.
	 */
	int x;
	
	/**
	 * Cell's y coordinate. 
	 */
	int y;
	
	/**
	 * Cell's height. 0 corresponds to a non-occupiable space. 
	 */
	int altitude = 1;
	
	/**
	 * Object which currently occupies this Cell. Default is no object.
	 */
	IFieldObject object = null;
	
	/**
	 * Cell's effect. Default is no effect.
	 */
	Effect cellEffect = null;
	
	/**
	 * Creates a Cell with the specified x and y coordinates and height.
	 * @param _x Cell's x coordinate
	 * @param _y Cell's y coordinate
	 * @param _height Cell's height
	 */
	public Cell(int _x, int _y) {
		x = _x;
		y = _y;
	}
	
	/**
	 * Checks whether this Cell is occupiable, i.e. its height is greater than 0.
	 * @return True if this Cell is occupiable, false otherwise
	 */
	public boolean isOccupiable() {
		return (altitude > 0);
	}
	
	/**
	 * Checks whether this Cell is occupied, i.e. no object is currently on it.
	 * @return True if this Cell is occupied, false otherwise. 
	 */
	public boolean isOccupied() {
		return (object == null);
	}
	
	/**
	 * Checks whether this Cell has an effect with trigger constant TRIGGER_MOVE_FROM.
	 * @return True if this Cell has an effect with trigger TRIGGER_MOVE_FROM
	 */
	public boolean hasMoveFromEffect() {
		return (cellEffect != null) && (cellEffect.triggers[Effect.TRIGGER_MOVE_FROM]);
	}
	
	/**
	 * Checks whether this Cell has an effect with trigger constant TRIGGER_MOVE_INTO.
	 * @return True if this Cell has an effect with trigger TRIGGER_MOVE_INTO
	 */
	public boolean hasMoveIntoEffect() {
		return (cellEffect != null) && (cellEffect.triggers[Effect.TRIGGER_MOVE_INTO]);
	}
}
